home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sml_nj / cml-098.lha / cml-0.9.8 / examples / ex-simple-comm.sml < prev    next >
Encoding:
Text File  |  1990-11-01  |  442 b   |  19 lines

  1. (* ex-simple-comm.sml
  2.  *
  3.  * COPYRIGHT (c) 1990 by John H. Reppy.  See COPYRIGHT file for details.
  4.  *
  5.  * A very simple example of process comunication.
  6.  *)
  7.  
  8. (* BEGIN EXAMPLE *)
  9. fun simple_comm () = let
  10.       val ch = channel()
  11.       val pr = CIO.print
  12.       in
  13.     pr "hi-0\n";
  14.     spawn (fn () => (pr "hi-1\n";  send(ch, 17);  pr "bye-1\n"));
  15.     spawn (fn () => (pr "hi-2\n";  accept ch;     pr "bye-2\n"));
  16.     pr "bye-0\n"
  17.       end
  18. (* END EXAMPLE *)
  19.